import java.util.Arrays;
import java.util.Scanner;

public class 找索引 {
        public static void main(String[] args){
            int[] arr={19,28,37,46,50};
            System.out.println("数组为："+ Arrays.toString((arr)));
            getInex(arr);
        }
        public static void getInex(int[] arr){
            System.out.println("请输入要查找的数据：");
            Scanner scanner=new Scanner(System.in);
            int number= scanner.nextInt();
            int a=0;

            for (int i=0; i<arr.length;i++){
                if (number==arr[i]){
                    a=i;
                    break;
                }
            }
            if(a==0){
                System.out.println("数据错误");}
            else{
                System.out.println(number+"索引值为："+a);
            }
        }

    }
